package com.yao.dubboconsumer.loadbalance.impl;

import com.yao.dubboconsumer.loadbalance.LoadBalance;

import java.util.List;
import java.util.Random;

/**
 * @author Henry Yao
 * @since 2021/5/3
 */
public class RandomLoadBalance implements LoadBalance {
    @Override
    public String doBalance(List<String> servers, Type type) {
        if (type == Type.RANDOM) {
            int i = new Random().nextInt(servers.size());
            return servers.get(i);
        }
        return null;
    }

}
